package demo_8_IO;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class bufferreader {
	public static void main(String[] args) {
		copyFile("d://wl_system.log", "d://wl_system1.log");
		
	}
  private static void copyFile(String src,String dec){
	  FileReader fr=null;
	  FileWriter fw=null;
	  BufferedReader br=null;
	  BufferedWriter bw=null;
	  String tempString="";
	  try {
		  fr=new FileReader(src);
		  fw=new FileWriter(dec);
		  br=new BufferedReader(fr);
		  bw=new BufferedWriter(fw);
		  while ((tempString=br.readLine())!=null) {
			bw.write(tempString);
		}
	  } catch (Exception e) {
		// TODO: handle exception
	}
	  finally{
		  try {
			bw.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		  try {
			br.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		  try {
			fw.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		  try {
			fr.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		  
	  }
  }
}
